<?php

namespace iBrand\Component\Order\Models;

use iBrand\Component\Discount\Models\Discount;
use Illuminate\Database\Eloquent\Model;
use Prettus\Repository\Contracts\Transformable;
use Prettus\Repository\Traits\TransformableTrait;
use Illuminate\Database\Eloquent\SoftDeletes;

class Adjustment extends Model implements Transformable
{
    const ORDER_DISCOUNT_ADJUSTMENT = 'order_discount';
    const ORDER_ITEM_DISCOUNT_ADJUSTMENT = 'order_item_discount';
    const ORDER_POINT_DISCOUNT_ADJUSTMENT = 'order_point_discount';
    const ORDER_WIPE_DISCOUNT_ADJUSTMENT = 'order_wipe_discount';
    const ORDER_ROUNDING_UP = 'order_rounding_up';
    const ORDER_NEW_USER_GIFT = 'order_new_user_gift';
    const ORDER_DOUBLE_ELE = 'order_double_ele';
    const ORDER_LEVEL_ELE = 'order_level_ele';

    use SoftDeletes;
    use TransformableTrait;

    protected $table = 'el_order_adjustment';

    protected $guarded = ['id'];

    public function order()
    {
        return $this->belongsTo(Order::class);
    }

    public function orderItem()
    {
        return $this->belongsTo(OrderItem::class);
    }

    public function orderItemUnit()
    {
        return $this->belongsTo(OrderItemUnit::class);
    }

    public function discount()
    {
        return $this->hasOne(Discount::class);
    }
}